#region Using directives

using System;
using System.IO;

using FighterChessEngine.Enum;
using FighterChessEngine.FC_Fighter;

#endregion

namespace FighterChessEngine.FC_Board
{
    /// <summary>
    /// Summary description for FighterPosition.
    /// </summary>
    public class Square
    {
        #region Atributes
        private int row;
        private int col;
        private SquareType type;
        #endregion

        #region Properties
        public int Row
        {
            get { return row; }
            set { row = value; }
        }
        public int Col
        {
            get { return col; }
            set { col = value; }
        }
        public SquareType Type
        {
            get { return type; }
            set { type = value; }
        }

        public string Informations
        {
            get
            {
                string info = "";
                switch (type)
                {
                    case SquareType.HpRestoreBlack:
                        info = "Black HP Restore Point";
                        break;
                    case SquareType.HpRestoreWhite:
                        info = "White HP Restore Point";
                        break;
                    case SquareType.LevelUpBlack:
                        info = "Black LevelUp Point";
                        break;
                    case SquareType.LevelUpWhite:
                        info = "White LevelUp Point";
                        break;
                    case SquareType.Random:
                        info = "TrY yOuR lUcK!!!";
                        break;
                    default: break;
                }

                return info;
            }
        }
        #endregion

        #region Methods
        public Square()
        {   
            row = 0;
            col = 0;
            type = SquareType.Unknown;
        }

        public Square(int row, int col, SquareType type)
        {
            this.row = row;
            this.col = col;
            this.type = type;
        }

        public Square(int row, int col)
            : this(row, col, SquareType.DontCare)
        {
        }

        public Square(Square pos) 
            : this(pos.Row, pos.Col, pos.Type)
        {
        }

        public Square(string strSquare)
        {
            // strSquare : row,col,type
            // ex: 0,1,1
            char[] sep = { ',' };
            string[] arrInfos = strSquare.Split(sep);
            row = int.Parse(arrInfos[0]);
            col = int.Parse(arrInfos[1]);
            type = (SquareType)int.Parse(arrInfos[2]);
        }

        public string ToSaveString()
        {
            string str = "";
            str += row.ToString() + ",";
            str += col.ToString() + ",";
            int iType = (int)type;
            str += iType.ToString();

            return str;
        }

        public bool Equals(Square square)
        {
            return (this.col == square.col 
                && this.row == square.row 
                && this.type == square.type);
        }
        #endregion
    }
}
